﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApp6
{
    public partial class Form1 : Form
    {
        
        public Form1()
        {
            InitializeComponent();
        }

        static void yanzheng(string s,string q)
        {
            string[] a = new string[1000];
            string[] b = new string[1000];
            FileStream afile = new FileStream(@"a.txt",FileMode.Open);
            StreamReader sr = new StreamReader(afile);
            int c = 0;
            string aLine;
            bool condition = true;

            while (true)
            {
               
                aLine = sr.ReadLine();

                if (aLine == null)
                {
                    condition = false;
                }

                if (condition)
                {
                    if (c % 2 == 0)
                    {
                        a[c / 2] = aLine;
                    }
                    else
                    {
                        a[(c - 1) / 2] = aLine;
                    }
                }
                else
                {
                    break;
                }
                c++;
            }
            int n = 0;
            for (int i = 0; i <= (c / 2); i++)
            {
                if (a[i] == s && b[i] == q)
                {
                    MessageBox.Show("登录成功");
                    /*页面跳转*/
                }
                else if (a[i] == s && b[i] != q)
                {
                    n = 1;
                }
                if (n == 0)
                {
                    MessageBox.Show("找不到用户名");
                }
                else if (n == 1)
                {
                    MessageBox.Show("密码错误");
                }
            }
            

        }

        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            
            textBox1.PasswordChar = '\0';
        }

        private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            textBox1.PasswordChar = '*';
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            yanzheng(textBox2.Text, textBox1.Text);
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}
